🎖️GitЯра🎖️
Node / meshtastic / Meshtastic-Android / files / feature / settings / src / commonMain / kotlin / org / meshtastic / feature / settings / component / CacheLimitPreference.kt
Displaying Raw • Download
feature/settings/src/commonMain/kotlin/org/meshtastic/feature/settings/component/CacheLimitPreference.kt 3796787cdfdf741db05a2d48aba32bc32275925b (3796787c) Text, 4.33 KB
T8b949e/*
* Copyright (c) 2026 Meshtastic LLC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
Tff7b72package T7ee787org.meshtastic.feature.settings.component
Tff7b72import T7ee787androidx.compose.runtime.Composable
Tff7b72import T7ee787androidx.compose.runtime.getValue
Tff7b72import T7ee787androidx.compose.runtime.mutableIntStateOf
Tff7b72import T7ee787androidx.compose.runtime.mutableStateOf
Tff7b72import T7ee787androidx.compose.runtime.remember
Tff7b72import T7ee787androidx.compose.runtime.rememberCoroutineScope
Tff7b72import T7ee787androidx.compose.runtime.saveable.rememberSaveable
Tff7b72import T7ee787androidx.compose.runtime.setValue
Tff7b72import T7ee787kotlinx.coroutines.launch
Tff7b72import T7ee787org.jetbrains.compose.resources.pluralStringResource
Tff7b72import T7ee787org.jetbrains.compose.resources.stringResource
Tff7b72import T7ee787org.meshtastic.core.database.DatabaseConstants
Tff7b72import T7ee787org.meshtastic.core.resources.Res
Tff7b72import T7ee787org.meshtastic.core.resources.apply
Tff7b72import T7ee787org.meshtastic.core.resources.are_you_sure
Tff7b72import T7ee787org.meshtastic.core.resources.cache_limit_eviction_warning
Tff7b72import T7ee787org.meshtastic.core.resources.cancel
Tff7b72import T7ee787org.meshtastic.core.resources.device_db_cache_limit
Tff7b72import T7ee787org.meshtastic.core.resources.device_db_cache_limit_summary
Tff7b72import T7ee787org.meshtastic.core.ui.component.DropDownPreference
Tff7b72import T7ee787org.meshtastic.core.ui.component.MeshtasticTextDialog
T8b949e/**
* Device DB cache limit dropdown, shared between the Android and Desktop settings screens. Lowering the limit below the
* number of currently-cached device databases evicts the least-recently-used ones and permanently deletes their local
* history, so a lower value is gated behind a confirmation showing how many devices would be affected. Raising or
* leaving the limit unchanged never evicts anything and applies immediately.
*/
Tf0883e@Composable
Tff7b72fun Td2a8ffCacheLimitPreferenceTb4b4b4(Te6edf3cacheLimitTb4b4b4: Tffa657IntTb4b4b4, Te6edf3onCheckEvictionCountTb4b4b4: Te6edf3suspend Tb4b4b4(Tffa657IntTb4b4b4) Tff7b72-Tff7b72> Tffa657IntTb4b4b4, Te6edf3onSetCacheLimitTb4b4b4: Tb4b4b4(Tffa657IntTb4b4b4) Tff7b72-Tff7b72> Tffa657UnitTb4b4b4) Tb4b4b4{
Tff7b72val Te6edf3cacheItems Tff7b72= Te6edf3remember Tb4b4b4{
Tb4b4b4(Te6edf3DatabaseConstantsTb4b4b4.Te6edf3MIN_CACHE_LIMITTb4b4b4.Tb4b4b4.Te6edf3DatabaseConstantsTb4b4b4.Te6edf3MAX_CACHE_LIMITTb4b4b4)Tb4b4b4.Te6edf3map Tb4b4b4{ Tffa657itTb4b4b4.Te6edf3toLongTb4b4b4(Tb4b4b4) Te6edf3to Tffa657itTb4b4b4.Te6edf3toStringTb4b4b4(Tb4b4b4) Tb4b4b4}
Tb4b4b4}
Tff7b72val Te6edf3scope Tff7b72= Te6edf3rememberCoroutineScopeTb4b4b4(Tb4b4b4)
Tff7b72var Te6edf3pendingLimit Tff7b72by Te6edf3rememberSaveable Tb4b4b4{ Te6edf3mutableStateOfTff7b72<Tffa657Int?Tff7b72>Tb4b4b4(Tff7b72nullTb4b4b4) Tb4b4b4}
Tff7b72var Te6edf3pendingEvictionCount Tff7b72by Te6edf3rememberSaveable Tb4b4b4{ Te6edf3mutableIntStateOfTb4b4b4(T79c0ff0Tb4b4b4) Tb4b4b4}
Tff7b72var Te6edf3selectionRequest Tff7b72by Te6edf3remember Tb4b4b4{ Te6edf3mutableIntStateOfTb4b4b4(T79c0ff0Tb4b4b4) Tb4b4b4}
Te6edf3DropDownPreferenceTb4b4b4(
Te6edf3title Tff7b72= Te6edf3stringResourceTb4b4b4(Te6edf3ResTb4b4b4.Te6edf3stringTb4b4b4.Te6edf3device_db_cache_limitTb4b4b4)Tb4b4b4,
Te6edf3enabled Tff7b72= Tff7b72trueTb4b4b4,
Te6edf3items Tff7b72= Te6edf3cacheItemsTb4b4b4,
Te6edf3selectedItem Tff7b72= Te6edf3cacheLimitTb4b4b4.Te6edf3toLongTb4b4b4(Tb4b4b4)Tb4b4b4,
Te6edf3onItemSelected Tff7b72= Tb4b4b4{ Te6edf3selected Tff7b72-Tff7b72>
Tff7b72val Te6edf3request Tff7b72= Tff7b72+Tff7b72+Te6edf3selectionRequest
Tff7b72val Te6edf3newLimit Tff7b72= Te6edf3selectedTb4b4b4.Te6edf3toIntTb4b4b4(Tb4b4b4)
Tff7b72if Tb4b4b4(Te6edf3newLimit Tff7b72>Tff7b72= Te6edf3cacheLimitTb4b4b4) Tb4b4b4{
Te6edf3onSetCacheLimitTb4b4b4(Te6edf3newLimitTb4b4b4)
Tb4b4b4} Tff7b72else Tb4b4b4{
Te6edf3scopeTb4b4b4.Te6edf3launch Tb4b4b4{
Tff7b72val Te6edf3evicted Tff7b72= Te6edf3onCheckEvictionCountTb4b4b4(Te6edf3newLimitTb4b4b4)
Tff7b72if Tb4b4b4(Te6edf3request Tff7b72!Tff7b72= Te6edf3selectionRequestTb4b4b4) Tff7b72returnTf0883e@launch
Tff7b72if Tb4b4b4(Te6edf3evicted Tff7b72> T79c0ff0Tb4b4b4) Tb4b4b4{
Te6edf3pendingEvictionCount Tff7b72= Te6edf3evicted
Te6edf3pendingLimit Tff7b72= Te6edf3newLimit
Tb4b4b4} Tff7b72else Tb4b4b4{
Te6edf3onSetCacheLimitTb4b4b4(Te6edf3newLimitTb4b4b4)
Tb4b4b4}
Tb4b4b4}
Tb4b4b4}
Tb4b4b4}Tb4b4b4,
Te6edf3summary Tff7b72= Te6edf3stringResourceTb4b4b4(Te6edf3ResTb4b4b4.Te6edf3stringTb4b4b4.Te6edf3device_db_cache_limit_summaryTb4b4b4)Tb4b4b4,
Tb4b4b4)
Te6edf3pendingLimitTff7b72?.Te6edf3let Tb4b4b4{ Te6edf3limit Tff7b72-Tff7b72>
Te6edf3MeshtasticTextDialogTb4b4b4(
Te6edf3titleRes Tff7b72= Te6edf3ResTb4b4b4.Te6edf3stringTb4b4b4.Te6edf3are_you_sureTb4b4b4,
Te6edf3message Tff7b72=
Te6edf3pluralStringResourceTb4b4b4(
Te6edf3ResTb4b4b4.Te6edf3pluralsTb4b4b4.Te6edf3cache_limit_eviction_warningTb4b4b4,
Te6edf3pendingEvictionCountTb4b4b4,
Te6edf3pendingEvictionCountTb4b4b4,
Tb4b4b4)Tb4b4b4,
Te6edf3confirmTextRes Tff7b72= Te6edf3ResTb4b4b4.Te6edf3stringTb4b4b4.Te6edf3applyTb4b4b4,
Te6edf3dismissTextRes Tff7b72= Te6edf3ResTb4b4b4.Te6edf3stringTb4b4b4.Te6edf3cancelTb4b4b4,
Te6edf3onConfirm Tff7b72= Tb4b4b4{
Te6edf3onSetCacheLimitTb4b4b4(Te6edf3limitTb4b4b4)
Te6edf3pendingLimit Tff7b72= Tff7b72null
Tb4b4b4}Tb4b4b4,
Te6edf3onDismiss Tff7b72= Tb4b4b4{ Te6edf3pendingLimit Tff7b72= Tff7b72null Tb4b4b4}Tb4b4b4,
Tb4b4b4)
Tb4b4b4}
Tb4b4b4}
Served by rngit 1.5.0 - Generated in 0.09s